-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Resource: aws_iot_thing #3521
Conversation
radeksimko
commented
Feb 25, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As usual, this is looking pretty good! Some minor comments below then should be ready to ship. 😄
Currently passing tests for me:
make testacc TEST=./aws TESTARGS='-run=TestAccAWSIotThing_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSIotThing_ -timeout 120m
=== RUN TestAccAWSIotThing_basic
--- PASS: TestAccAWSIotThing_basic (10.59s)
=== RUN TestAccAWSIotThing_full
--- PASS: TestAccAWSIotThing_full (329.40s)
=== RUN TestAccAWSIotThing_importBasic
--- PASS: TestAccAWSIotThing_importBasic (8.98s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 349.011s
aws/resource_aws_iot_thing.go
Outdated
} | ||
|
||
d.SetId(*out.ThingName) | ||
d.Set("arn", out.ThingArn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Extraneous set here
aws/resource_aws_iot_thing.go
Outdated
Delete: resourceAwsIotThingDelete, | ||
|
||
Importer: &schema.ResourceImporter{ | ||
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we could use the passthrough importer here unless I'm missing something 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a piece of code I somehow forgot here as I was refactoring the CRUD.
aws/resource_aws_iot_thing.go
Outdated
log.Printf("[DEBUG] Received IoT Thing: %s", out) | ||
|
||
d.Set("arn", out.ThingArn) | ||
d.Set("attributes", aws.StringValueMap(out.Attributes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
aws/resource_aws_iot_thing.go
Outdated
log.Printf("[DEBUG] Deleting IoT Thing: %s", params) | ||
|
||
_, err := conn.DeleteThing(params) | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return nil
on iot.ErrCodeResourceNotFoundException
here?
aws/resource_aws_iot_thing_test.go
Outdated
}) | ||
} | ||
|
||
func testAccCheckAWSIotThingDestroy(s *terraform.State) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there also be an associated testAccCheckAWSIotThingExists
?
aws/resource_aws_iot_thing_test.go
Outdated
} | ||
|
||
_, err := conn.DescribeThing(params) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we flip this around to return nil
on iot.ErrCodeResourceNotFoundException
error and return the actual error on others (e.g. permission errors)?
Creates and manages an AWS IoT Thing. | ||
--- | ||
|
||
# aws_iot_thing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ## Import
documentation
@bflad PTAL, I believe I addressed all your comments 😉
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just one minor thing that you can turbo merge in to fix an error message in the testing.
make testacc TEST=./aws TESTARGS='-run=TestAccAWSIotThing_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSIotThing_ -timeout 120m
=== RUN TestAccAWSIotThing_basic
--- PASS: TestAccAWSIotThing_basic (9.73s)
=== RUN TestAccAWSIotThing_full
--- PASS: TestAccAWSIotThing_full (338.24s)
=== RUN TestAccAWSIotThing_importBasic
--- PASS: TestAccAWSIotThing_importBasic (8.32s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 356.333s
} | ||
|
||
_, err := conn.DescribeThing(params) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aw shucks - just missing a return err
in here, otherwise we print out the wrong message below
This has been released in version 1.11.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |